package com.hx.vending.controller;

import com.hx.vending.annotation.Authorization;
import com.hx.vending.annotation.CurrentUserId;
import com.hx.vending.service.IDrawCashService;
import com.hx.vending.util.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2018/12/29.
 * 提现申请
 */
@Controller
@RequestMapping("/drawCash")
public class DrawCashController {

    @Autowired
    private IDrawCashService iDrawCashService;

    /**
     * 商户申请提现
     * @param userId
     * @param money
     * @return
     */
    @PostMapping("/insertApplyForDrawCash")
    @ResponseBody
    @Authorization
    public Msg insertApplyForDrawCash(@CurrentUserId Integer userId, Double money,Integer type) {
        return this.iDrawCashService.insertApplyForDrawCash(userId, money,type);
    }


    /**
     * 后台查询提现申请
     * @param pageNum
     * @param pageSize
     * @return
     */
    @PostMapping("/selectDrawCash")
    @ResponseBody
    public Msg selectDrawCash(@RequestParam(value = "pageNum", defaultValue = "1")Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize) {

        return this.iDrawCashService.selectDrawCash(pageNum, pageSize);
    }


    /**
     * 后台同意提现
     * @param userWithdrawId
     * @return
     */
    @PostMapping("/updateAgreeDrawCash")
    @ResponseBody
    public Msg updateAgreeDrawCash(Integer userWithdrawId) {

        return this.iDrawCashService.updateAgreeDrawCash(userWithdrawId);
    }

    /**
     * 后台提现未通过
     * @param userWithdrawId
     * @return
     */
    @RequestMapping("/notAgreeDrawCash")
    @ResponseBody
    public Msg notAgreeDrawCash(Integer userWithdrawId){
        return this.iDrawCashService.notAgreeDrawCash(userWithdrawId);
    }



}
